﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NewStart
{
    public partial class EditTile : Form
    {
        Tile t;

        public EditTile(Tile tile)
        {
            InitializeComponent();            
            t = tile;
            checkBox1.Checked = t.LargeTile;
            textBox1.Text = t.Text;
            textBox2.Text = t.path;
            textBox3.Text = t.iconpath;
            this.ShowDialog(tile);
        }

        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            Graphics g = pevent.Graphics;
            Rectangle rBackground = new Rectangle(0, 0, this.Width, this.Height);
            System.Drawing.Drawing2D.LinearGradientBrush bBackground
               = new System.Drawing.Drawing2D.LinearGradientBrush(rBackground, Color.White, Color.LightGray, 30);
            g.FillRectangle(bBackground, rBackground);
            bBackground.Dispose();
        }

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ClassStyle |= 0x00020000;
                return cp;
            }
        }

        private void metroIcon1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            t.LargeTile = checkBox1.Checked;
            t.Text = textBox1.Text;
            t.path = textBox2.Text;
            t.iconpath = textBox3.Text;

            CycleForm.m.ReloadTiles();
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog();
            if (o.ShowDialog() == DialogResult.OK)
                textBox2.Text = o.FileName;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog();
            if (o.ShowDialog() == DialogResult.OK)
                textBox3.Text = o.FileName;
        }
    }
}
